#ifndef CELLPARTICLES_H
#define CELLPARTICLES_H

#include<vector>

#include "../Input/PicParams.h"

using namespace std;

class PicParams;
class SpeciesParameter;


template<int dim>
struct Particle
{
    double position[dim];
    double velocity[3];
    
    Particle(){};
};


template<int dim>
class CellParticles
{
public:
    //constructor
    CellParticles();

    //destructor
    ~CellParticles();

    void initialize(const PicParams* params, const SpeciesParameter& species_param, const vector<double>& cell_min, const vector<double>& cell_length);

    void reinitialize_particles(const PicParams* params, const SpeciesParameter& species_param, const vector<double>& cell_min,
                                const vector<double>& cell_length, const vector<double>& mean_velocity, double temperature, int number_particles);

    void add_particles(const PicParams* params, const SpeciesParameter& species_param, const vector<double>& cell_min,
                                const vector<double>& cell_length, const vector<double>& mean_velocity, double temperature, int number_particles);

    //only increace particle size, not initialize velocity and position
    void add_particles(int number_particles);

    void heat(const PicParams* params, const SpeciesParameter& species_param, double temperature_heat);
    void heat_new(const PicParams* params, const SpeciesParameter& species_param, const ParticleSourceParameter& ps_param, double energy_heat);
    void heat_new2(const PicParams* params, const SpeciesParameter& species_param, const ParticleSourceParameter& ps_param, double energy_heat);

    //set capacity of Particles vectors
    void reserve(int n_part_max);

    //reset Particles vectors
    void clear();

    //get number of particles
    inline int size() const 
    {
        return data_.size();
    }

    //get number of particles
    inline int capacity() const 
    {
        return data_.capacity();
    }

    //add_new_particle
    inline void add_new_particle(Particle<dim> particle)
    {
        data_.push_back(particle);
    }

    inline void add_particle_delete_list(int i_particle)
    {
        particle_delete_list_.push_back(i_particle);
    }

    void delete_useless_particles();

    vector<Particle<dim>> data_;

    vector<int> particle_delete_list_;
};


#endif
